package lab02.Test23;

/**
 * Created by lady on 2017/10/31.
 */
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.*;
public class Birthday {
        public static void main(String[] args) {

            //行为：命令行输入你的生日信息，
            SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
            Date dateNow=new Date();
            Date date=null;
            Scanner scanner=new Scanner(System.in);
            System.out.println("请输入您的生日（格式）：xxxx-xx-xx:");
            String s=scanner.nextLine();
            try {
                date=dateFormat.parse(s);}
            catch (Exception e){
                System.out.println("输入错误");
            }
            //计算你的生日还有多少天，你的生日是星期几。
            Calendar calendar=Calendar.getInstance();
            calendar.setTime(date);
            Date dateBirthay=calendar.getTime();
            System.out.println("您的生日是星期：");
            System.out.println(calendar.get(Calendar.DAY_OF_WEEK));
            long countDay=(dateBirthay.getTime()-dateNow.getTime())/(24*60*60*1000);
            while (countDay<=0){
                countDay+=365;
            }
            System.out.println("您的生日还有"+countDay+"天。");
        }
    }

